def filename_cop(filename):
    """
    输入文件的路径进行备份，产用二进制备份，可以备份各类型文件，输入备份后的文件名
    :param filename: 需备份的文件
    :return: 备份后的新文件名
    """
    old_name = filename
    index = filename.rfind('.')
    new_name = filename[:index] + '[备份]' + filename[index:]
    r = open(old_name, 'rb')
    w = open(new_name, 'wb')
    while True:
        r_1024 = r.read(1024)
        if len(r_1024) == 0:
            break
        w.write(r_1024)
    r.close()
    w.close()
    return new_name


print(filename_cop('九九乘法表.py'))
